{# SPDX-FileCopyrightText: © 2014-2015 Siemens AG

   SPDX-License-Identifier: FSFAP
#}
  <script src="scripts/job-queue-poll.js" type="text/javascript"></script>
  <script>
    var resultEntity = $("#jobResult");

    function linkDownloadReport() {
      resultEntity.html("<a href='{{ downloadLink }}'>Download {{ reportType }} report</a>");
      window.location = "{{ downloadLink }}";
    }
    function genereationFailed(jqPk) {
      var text = (jqPk > 0) ? linkToJob(jqPk) : "no job scheduled";
      resultEntity.html("{{ reportType }} generation failed: " + text);
    }

    function addLinkAndQueueAjaxPolling() {
      var jqPk = {{ jqPk }};
      if (jqPk > 0)
      {
        resultEntity.html("{{ reportType }} report generation scheduled as " + linkToJob(jqPk));
        queueUpdateCheck(jqPk, linkDownloadReport, genereationFailed);
      }
      else
      {
        genereationFailed();
      }
    }

    $(document).ready(function () {
      addLinkAndQueueAjaxPolling();
    });
  </script>
